package com.gyz.cfmall.product.config;

import org.eclipse.jetty.util.BlockingArrayQueue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author gong_yz
 * @Description 线程池类
 * @Date 2023/4/3 14:53
 */
@Configuration
public class MyThreadPoolConfig {
    @Bean
    public ThreadPoolExecutor threadPoolExecutor(ThreadPoolConfigProperties pool) {
        return new ThreadPoolExecutor(
                pool.getCoreSize(),
                pool.getMaxSize(),
                pool.getKeepAliveTime(),
                TimeUnit.SECONDS,
                new BlockingArrayQueue<>(100000),
                new ThreadPoolExecutor.AbortPolicy()
        );
    }
}
